<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html> 
<head>
<%@ include file="../../../include/easyui.jsp" %>
<%@ include file="../../../include/pGrid.jsp" %>
<title>我的事务</title>
<script>
	function openBusinessForm(businessKey){
		var bk = businessKey.split("\.");
		var url = '/console/com.fs.jzzn.pojo.className/json';
		url = url.replace('className',bk[0]);
		var param = {id:bk[1],id_searchType:'eq'};
		$.getJSON(url, param , function(data){
			if(data){
				if(bk[0]=='Expense'){
					url = '/console/expense/view';
					p.gridView({href: url ,title : "流程业务表单查看" ,width : 650, height : 460 ,autoMax:true,data: data });
				}
			}
		}); 
	}
	$(function(){
		/*列表初始化*/
		var gridParam = {
			queryParams:{
				all: '${param.all}' || '' ,
			},	
			url :'/console/activiti/deploy/processInstanceList',
			columns : [ [ 
				{field : 'id',width : 120,title : 'ID'}
				,{field : 'defId',width : 120,title : '流程定义id'}
				,{field : 'affairTitle',width : 200,title : '流程事务标题',formatter:function(value,row,index){
					/*var businessKey = row.businessKey.split(".");
					var url = "/console/"+ businessKey[0]+ "/view/"+businessKey[1];
					return '<a href="#">'+ value + '</a>';*/
					return '<a href="#" onclick="openBusinessForm(\'' + row.businessKey +'\')" >'+ value+'</a>';
				}}
				,{field: 'createTime', title: '开始时间', width: 130}
				,{field: 'endTime', title: '结束时间', width: 130}
				,{field: 'createrId', title: '发起人', width: 120}
				,{field: 'status', title: '状态', width: 120,formatter:function(value,row,index){
					return (row.endActId) ? '完结' : value ;
				}}
				,{field: 'opt', title: '流程图片', width: 150,formatter:function(value,row,index){
					//if(row.endActId) return null;
					return  '<a target="_blank" href="/console/activiti/viewImageByInstId?instId='+ row.id+ '">查看当前流程图</a>';
			    }}
			]],
			onLoadSuccess: function(){
				p.tooltip(['affairTitle' ]);
			}
		};
		p.dataGrid = $(p.dataGrid).datagrid( $.extend({}, p.dataGridParam, gridParam));

		/*事件响应*/
		$("#toolbar .easyui-linkbutton").on("click", function() {
			var id = $(this).attr("motion_code");
			switch (id) {
				case "03":
					p.gridDelete({ msg:"您确认删除当前选中流程实例？",url:'/console/activiti/processInstanceDelete' });
					break;
				case "05":
					p.gridQuery();
					break;
				default: 
					p.tip({msg: $(this).text() +'未添加响应事件！'}); break;
			}
		});
	});
</script>
</head>
<body  class="easyui-layout">
		<!-- 但行高度33px，多行时 33乘以行数  -->
		<div id="querybar" data-options="region:'north',split:false,border:false" style="height:33px;">
			<div class="easyui-panel" data-options="fit:true,border:false">
				<!-- 查询条件表单，根据配置进行替换  -->
				<form id="queryForm" >
				 <input type="hidden" name="className" value="com.fs.base.pojo.Log" />
				 <div style="margin-top:5px;margin-left:10px;float:left;">
				  	<input class="easyui-textbox" name="name" style="width:240px;" data-options="label:'流程名称:',required:false" />
					<input type="hidden" name="name_searchType" value="like" />
				 </div>
				</form>
			</div>
		</div>  
	
		<!-- 工具栏按钮 -->
		<div id="toolbar" class="easyui-panel" style="padding:3px;"></div>
		
		<!-- 表格 -->
		<div region="center" border="false">
			<table id="dataGrid"></table>
		</div>
</body>
</html>